package com.example.shopping_web_back.mapper;

import com.example.shopping_web_back.pojo.Customer;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

//主要用于定义顾客(用户)的与数据库有关的操作
@Mapper
public interface CustomerMapper {

    //从顾客信息表中提取出指定顾客名字的所有信息
    @Select("select * from shoppingweb.customer_information where name = #{customerName}")
    Customer findByCustomerName(String customerName);

    //向顾客表中插入新的数据
    @Insert("insert into shoppingweb.customer_information(name,password)" +
            " value(#{customerName},#{password})")
    void add(String customerName, String password);

    @Update("update shoppingweb.customer_information set email=#{email}, telephone=#{telephone} where id=#{id}")
     void update(Customer customer);

    @Update("update shoppingweb.customer_information set image=#{imageUrl} where id=#{id}")
    void updateImage(String imageUrl, Integer id);

    @Update("update shoppingweb.customer_information set password=#{newPwd} where id=#{id}")
    void updatePassword(String newPwd, Integer id);
}
